//InnerAudioContext实例
const app = getApp()
//InnerAudioContext实例
var audioCxt;
//动画
var audioAnimation;
audioCxt = wx.createInnerAudioContext();
audioCxt.src = 'https://zhimi-lake.oss-cn-beijing.aliyuncs.com/audio/daziqin0.mp3';
 
Page({
  data: {
    play:0,
    ok1:0,
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
    //在播放状态，绑定播放进度更新事件。然后控制进度条和时间显示
    audioCxt.onPlay((res) =>{ 
      //audioCxt.onTimeUpdate(this.timeUpdate)
      console.log('播放start')
    }),
    //音乐播放结束触发
    audioCxt.onEnded((res)=>{
      audioCxt.seek(0);
      console.log('播放end')
    })
  },
  onLoad:function(){
    let x1 = this.data.x1;
    let y1 = this.data.y1;
    let x5 = this.data.x5;
    let y5 = this.data.y5;
    console.log('x1==='+x1+' y1==='+y1 +' x5==='+ x5+' y5==='+y5);
  },
 
    //播放按钮事件
    playMusic : function(e){
      var that = this;
      let play = e.currentTarget.dataset.play;
      var mp3 = 'https://zhimi-lake.oss-cn-beijing.aliyuncs.com/audio/daziqin'+play+'.mp3';
      audioCxt.src = mp3;
      audioCxt.play();
    },
        //暂停按钮事件
        pauseMusic : function(){
          audioCxt.pause();
        },
  
  resetKey(){
    this.setData({
      isok:'',
      play1:0,
    play2:0,
    play3:0,
    play4:0,
    })
    wx.redirectTo({
      url: '../lock/test4',
    })
  },
  isOk(){
    let isok = this.data.isok;
    var words = isok.split(",");
    words = this.uniqueStr(words);
    isok = words.join(',');
    let tip = '再想想!';
    if(isok == '2,4,1,3,'){
      console.log('锁开了!')
      tip = '锁开了!';
    }
    else{
      console.log('2413再想想!'+ isok)
    }
    wx.showModal({
      title: '提示',
      content: tip,
      success: (res) => {
          // wx.switchTab({
          //   url: '/pages/strategyList/strategyList'
          // })                
      }
    })
  },

  uniqueStr (array){
    return array.filter(function(el, index, arr) {
    return index == arr.indexOf(el);
    });
  },

})